//
//  GroupedListProtocol.swift
//  whale
//
//  Created by topnet on 2022/7/4.
//

import UIKit


protocol GroupedListModelProtocol {
    ///当设置时 以设置为准 否则取headerV.height
    var headerHeight: CGFloat? { get set }
    ///当设置时 以设置为准 否则取footerV.height
    var footerHeight: CGFloat? { get set }
    
    var rowHeight: CGFloat? { get set }
    
    var rows: [TableCellModelProtocol]? { get set }
    
    var headerVType: GroupedListSectionView.Type? { get set }
    var headerV: GroupedListSectionView? { get }
    var footerVType: GroupedListSectionView.Type? { get set }
    var footerV: GroupedListSectionView? { get }
    
    var cellType: WhaleListCell.Type? { get set }
    

}

extension GroupedListModelProtocol {
        
    var headerV: GroupedListSectionView {
        let v = headerVType?.init() ?? GroupedListSectionView()
        v.md = self
        return v
    }

    var footerV: GroupedListSectionView {
        let v = footerVType?.init() ?? GroupedListSectionView()
        v.md = self
        return v
    }
}

protocol TableCellModelProtocol {
    var rowHeight: CGFloat? {get set}
    var cellType: WhaleListCell.Type? { get set }
    
}

protocol TableCellProtocol {
    var md: TableCellModelProtocol { get set }
}

protocol GroupedListProtocol {
    
    var cellType: WhaleListCell.Type? { get set }
    func didSelect<T, U>(cell: T, md: U)
}
